package com.credit.repository;

import java.util.List;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.credit.entity.CreditUserIdentify;
import com.credit.entity.CreditUserInfo;
import com.credit.util.CodeValueUtil;

public interface UserDao extends PagingAndSortingRepository<CreditUserInfo, Long>, JpaSpecificationExecutor<CreditUserInfo> {

	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
	CreditUserInfo findByMobile(String mobile);

	@Modifying 
	@Query("update CreditUserInfo u set u.password = ?1 where u.id = ?2")
	void update(String password, Long id);

	@Query("select id from CreditUserInfo u where u.pushCity = ?1 and u.userType=1 and identifyCheck=1")
	List<Long> findUserByCurrentCity(String currentCity);

	@Query("from CreditUserIdentify identify where identify.userId = ?1")
	CreditUserIdentify findIdentifyByUId(Long uId);
	
/*	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
	CreditUserInfo register(String mobile,String password);*/
	
	
	
	
}
